<template>
    <div>
        <template v-for="(item,index) in menu_data">
            <el-submenu :index="String(item.id)" v-if="item.children" :key="index">
                <template slot="title">
                    <i :class="item.icon"/>
                    <span slot="title">{{item.name}}</span>
                </template>
                <Menu :menu_data="item.children"/>
            </el-submenu>
            <el-menu-item :index="item.url" v-else @click="menu_select(item)" :key="item.id">
                <template slot="title">
                    <i :class="item.icon"/>
                    <span slot="title">{{item.name}}</span>
                </template>
            </el-menu-item>
        </template>
    </div>
</template>

<script>
    export default {
        name: "Menu",
        props: {
            menu_data: Array
        },
        methods: {
            menu_select(itemObj) {
                this.$store.commit('addOpenedMenu',itemObj)
            }
        }
    }
</script>

<style scoped>

</style>